package dao

import (
	"elflog/common/context"
	"elflog/common/dig"
	"elflog/component/ndb"
	"elflog/component/nlog"
	"elflog/module/module-log/model"
)

type LogDao struct {
	log *nlog.NLog
	Dao *ndb.NDb
}

func NewLogDao(log *nlog.NLog, dao *ndb.NDb) *LogDao {
	err := dao.GetDb(context.NewContext()).AutoMigrate(new(model.Log)).Error
	if err != nil {
		panic(err)
	}
	return &LogDao{
		log: log,
		Dao: dao,
	}
}

func init() {
	dig.Container.MustProvide(NewLogDao)
}
